package demo05;

import java.util.ArrayList;
import java.util.Scanner;

public class Test02ArrayList {
    public static void main(String[] args) {
        ArrayList<Student> Studentlist=new ArrayList<>();
//        Student stu1=new Student("张三",18);
//        Student stu2=new Student("李四",20);
//        Student stu3=new Student("王五",21);
//        Student stu4=new Student("刘六",19);
        Scanner s=new Scanner(System.in);
        for (int i = 0; i < 4; i++) {
            System.out.println("请输入第"+(i+1)+"个学生的姓名和年龄");
            Studentlist.add(new Student(s.next(),s.nextInt()));
        }
        for (int j = 0; j < Studentlist.size(); j++) {
            System.out.println(Studentlist.get(j).getName()+Studentlist.get(j).getAge());
        }
    }
}
